
from bcat.error import AbstractError


class CommandNotFoundError(AbstractError):
    def __init__(self, cmd: str, msg: str = ""):
        msg = f"{msg}, cmd:[{cmd}]" if len(msg) > 0 else f"command:[{cmd}] not found"
        super().__init__(msg)
        self.__cmd = cmd

    def cmd(self):
        return self.__cmd

    def __repr__(self):
        return f"CommandNotFoundError(cmd={self.cmd()}, msg={self.msg()})"
        

class TimeoutExpired(AbstractError):
    def __init__(self, timeout: int | None, msg: str = ""):
        msg = f"{msg}, timeout:[{timeout}]" if len(msg) > 0 else f"timeout expired:[{timeout}]"
        super().__init__(msg)
        self.__timeout = timeout

    def timeout(self):
        return self.__timeout

    def __repr__(self):
        return f"TimeoutExpired(timeout={self.timeout()}, msg={self.msg()})"
        
